#ifndef     __FRAME_H
#define     __FRAME_H

extern "C" {
#include <libavutil/frame.h>
}
#include <utility>
#include "../../utils/nocopyable.h"

struct Frame : private utils::NoCopyable {

    // av_frame_alloc()
    Frame(AVFrame *f = nullptr) : frame(f) {}

    Frame(Frame &&other) {
        frame = other.frame;
        other.frame = nullptr;
    }

    ~Frame() {
        if (frame != nullptr) {
            av_frame_free(&frame);
        }
    }

    Frame& operator=(Frame &&other) {
        std::swap(frame, other.frame);
        return *this;
    }

    void unref() {
        av_frame_unref(frame);
    }

    inline AVFrame* operator->() {
        return frame;
    }

    AVFrame *frame;
};





#endif
